-- TL_GuildRepair by Amandria of Tempest Legends (Blackmoore EU)
-- $Id: Core.lua 15 2008-01-14 23:35:13Z maaki@gmx.de $
-- http://code.google.com/p/tl-wow/

local options = {
	type = 'group',
	args = {
		about = {
			type = 'execute',
			name = 'about',
			desc = 'Show information on this Addon',
			func = 'About',
		},
		scan = {
			type = 'execute',
			name = 'scan',
			desc = 'Scan guild Ranks',
			func = 'ScanRanks',
		},
	},
};


GuildRepair = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceEvent-2.0", "FuBarPlugin-2.0")
GuildRepair:RegisterChatCommand("/guildrepair", "/gr", options);


function GuildRepair:OnInitialize()
	self.OnMenuRequest = options;
end

function GuildRepair:OnEnable()
	self:Print(" v." .. self.version .. " loaded.");
end

function GuildRepair:OnDisable()
	self:Print(" v." .. self.version .. " unloaded.");
end

function GuildRepair:OnTextUpdate()
	self:SetText("GR");
end

function GuildRepair:ScanRanks()
	local nRanks = GuildControlGetNumRanks();
	for i = 1, nRanks do
		GuildControlSetRank(i);
		self:Print("GBank withdraw limit for rank " .. i .. " " .. GuildControlGetRankName(i));
		local rRepair = select(14, GuildControlGetRankFlags());
		if (rRepair == 1) then
			self:Print(GetGuildBankWithdrawLimit() .. " (repair only)");
		else
			self:Print(GetGuildBankWithdrawLimit());
		end
	end
end

function GuildRepair:About()
	self:Print(" v." .. self.version .. " by " ..  self.author .. ".");
end
